package com.neusoft.a312cxy.android18cxy.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.neusoft.a312cxy.android18cxy.R;
import com.neusoft.a312cxy.android18cxy.bean.ShaiTuInfo;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Young on 2017/10/16.
 */

public class ShaiTuInfoAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List<ShaiTuInfo> mDataList1;
    private LayoutInflater mLayoutInflater;


    public ShaiTuInfoAdapter(Context mContext, List<ShaiTuInfo> mDataList) {
        this.mContext = mContext;
        this.mDataList1 = mDataList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public  ShaiTuInfoAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mLayoutInflater.inflate(R.layout.cardview_shaituinfo, parent, false);
        return new ShaiTuInfoAdapter.ViewHolder(v);


    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final ShaiTuInfo entity =  mDataList1.get(position);
        if (null == entity)
            return;
        ShaiTuInfoAdapter.ViewHolder viewHolder = (ShaiTuInfoAdapter.ViewHolder) holder;
        viewHolder.replyneirong.setText(entity.getReply());
        viewHolder.reply_time.setText(entity.getReply_time());
        viewHolder.user_name.setText(entity.getUser_name());

        if(entity.getPhoto()!=null)
        {
            Picasso.with(mContext).load("http://172.24.10.175/workout/Uploads/"+entity.getPhoto()).into(viewHolder.photo);
        }
        else
        {
            viewHolder.photo.setImageResource(R.drawable.ic_club);
        }



    }

    @Override
    public int getItemCount() {
        return mDataList1.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView photo;
        TextView  replyneirong, reply_time,user_name;




        public ViewHolder(View itemView) {
            super(itemView);
            photo= (ImageView) itemView.findViewById(R.id.photo);
            replyneirong = (TextView) itemView.findViewById(R.id.replyneirong);
            reply_time= (TextView) itemView.findViewById(R.id.reply_time);
            user_name=(TextView) itemView.findViewById( R.id.user_name);



        }
    }

 /*   public void upreply(String shaitu_id,String userid,String 	reply_userid final PostListener postListener){

    }*/
}
